import { removeCate as removeCateApi } from '@/api/cate'

import { Modal, message } from 'ant-design-vue'

export default function removeCate(cate_id: string, cb: Function) {
  let modal = Modal.confirm({
    title: '提示',
    content: '您确定要删除此分类吗？',
    onOk() {
      return new Promise((resolve, reject) => {
        // resolve(1)
        removeCateApi({
          cate_id
        }).then((res: any) => {
          if (res.code === 0) {
            message.success(res.msg)
            cb()
          } else {
            message.warn(res.msg)
          }

          modal.destroy()
        })
      }).catch(() => console.log('Oops errors!'))
    }
  })
}
